package com.ohs.ohsoa.system.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ohs.ohsoa.system.dto.ScheduleTypeDto;
import com.ohs.ohsoa.system.entity.ScheduleType;
import com.ohs.ohsoa.system.mapper.ScheduleTypeMapper;
import com.ohs.ohsoa.system.vo.ScheduleTypeVo;
import com.ohs.ohsoa.utils.bean.requestBean.PageParam;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日程类别实现类
 *
 * @author ss
 *
 */
@Service
public class ScheduleTypeServiceImpl extends ServiceImpl<ScheduleTypeMapper, ScheduleType> implements ScheduleTypeService {
    @Resource
    private ScheduleTypeMapper scheduleTypeMapper;

//    @Override
//    public List<WorkNotesVo> workNotesSelectList(PageParam<WorkNotesDto> pageParam) {
//        // 获取工作笔记对象
//        WorkNotesDto workNotesDto = pageParam.getSearchbean();
//        // 分页
//        PageHelper.startPage(pageParam.getIndexPage(), pageParam.getPageSize());
//        return workNotesMapper.workNotesSelectList(workNotesDto);
//    }

    @Override
    public List<ScheduleTypeVo> scheduleTypeSelectList(PageParam<ScheduleTypeDto> pageParam) {
        // 获取日程类别对象
        ScheduleTypeDto scheduleTypeDto = pageParam.getSearchbean();
        // 分页
        PageHelper.startPage(pageParam.getIndexPage(), pageParam.getPageSize());
        return  scheduleTypeMapper.scheduleTypeSelectList(scheduleTypeDto);
    }

    @Override
    public ScheduleTypeVo scheduleTypeSelect(ScheduleTypeDto scheduleTypeDto) {
        ScheduleType scheduleType = this.getById(scheduleTypeDto.getStId());
        ScheduleTypeVo scheduleTypeVo = new ScheduleTypeVo();
        BeanUtils.copyProperties(scheduleType,scheduleTypeVo);
        return scheduleTypeVo;
    }

    @Override
    public Boolean scheduleTypeInsert(ScheduleTypeDto scheduleTypeDto) {
        ScheduleType scheduleType = new ScheduleType();
        BeanUtils.copyProperties(scheduleTypeDto,scheduleType);
        return this.save(scheduleType);
    }

    @Override
    public Boolean scheduleTypeDelete(ScheduleTypeDto scheduleTypeDto) {
        return scheduleTypeMapper.scheduleTypeDelete(scheduleTypeDto.getStIds());
    }

    @Override
    public Boolean scheduleTypeUpdate(ScheduleTypeDto scheduleTypeDto) {
        ScheduleType scheduleType = new ScheduleType();
        BeanUtils.copyProperties(scheduleTypeDto,scheduleType);
        return this.updateById(scheduleType);
    }

}
